﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SC.GirdManage.Common;
using SC.GridManage.API.Write.Application.Command.LogicGrid;
using SC.GridManage.Domain.Models;

namespace SC.GridManage.API.Write.Controllers
{
    /// <summary>
    /// 逻辑网格控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LogicGridController : ControllerBase
    {
        private readonly IMediator mediator;

        public LogicGridController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加逻辑网格接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> CreateLogicGird(CreateLogicGirdCommand request) { 
            return mediator.Send(request);
        }
        /// <summary>
        /// 删除逻辑网格的接口
        /// </summary>
        /// <param name="commond"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> DeleteLogicGrid(DelLogicGridCommand commond)
        {
           return mediator.Send(commond);
        }
        /// <summary>
        /// 更新逻辑网格的接口
        /// </summary>
        /// <param name="commond"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateLogicGrid(UpdLogicGridCommand commond)
        {
           return mediator.Send(commond);
        }
    }
}
